package com.ecp.commons.filter;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

import org.apache.commons.lang.StringUtils;

public class MultiMerchantIdFilter extends AbstractExcludeUrlFilter {

	private static final long	serialVersionUID	= 1L;

	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
			ServletException {
		String strMid = request.getParameter("mid");
		String defaultMid = this.getInitParameter("defaultMid");
		int mid = 0;
		try {
			mid = Integer.parseInt(defaultMid);
		} catch (Exception ex) {
		}
		if (StringUtils.isNotBlank(strMid)) {
			try {
				mid = Integer.parseInt(strMid);
			} catch (Exception ex) {
			}
		}
		request.setAttribute("frontMid", new Integer(mid));
		chain.doFilter(request, response);

	}

}